Skip to content

feat(zipapp): add windows support#3561

Merged
rickeylev merged 24 commits intobazel-contrib:mainfrom
rickeylev:pyzipapp.windows
Feb 6, 2026
Merged

feat(zipapp): add windows support#3561
rickeylev merged 24 commits intobazel-contrib:mainfrom
rickeylev:pyzipapp.windows

Conversation

@rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Feb 2, 2026

This adds Windows support to the py_zipapp rules.

It works the same as what py_binary does: the Bazel builtin launcher.exe is
populated with the path to the zip, and the exe then handles starting Python
and running the zip.

This should be the last of the implementation, so all that remains is
deprecating the code in py_binary and removing it.

Work towards #2586

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request is a work-in-progress to extend the py_zipapp rules to fully support Windows. It introduces the necessary logic to create native Windows executables for Python zip applications, adapting the build process to the Windows environment. The changes include platform-specific launcher generation and updates to the build rule attributes and test configurations to enable Windows compatibility.

Highlights

  • Windows Launcher Creation: Introduced a new function, _create_windows_exe_launcher, to generate platform-specific .exe launchers for Python zip applications on Windows, ensuring proper execution and runfiles handling.
  • Conditional Executable Generation: Modified the _py_zipapp_executable_impl function to conditionally produce a Windows .exe output for py_zipapp_binary targets when the build is targeting a Windows platform, alongside the standard zip file.
  • New Rule Attributes for Windows Support: Added several new attributes to the py_zipapp_binary rule, including _launcher, _windows_constraints, and a conditional _windows_launcher_maker, to facilitate the Windows-specific build logic and toolchain integration.
  • Test Configuration Updates: Updated the BUILD.bazel file in the tests/py_zipapp directory by commenting out target_compatible_with = NOT_WINDOWS for various targets, thereby enabling these tests and binaries to be built and run on Windows as part of the ongoing development.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds Windows support to the py_zipapp rules by introducing logic to create a Windows .exe launcher. The implementation in py_zipapp_rule.bzl appears solid, correctly handling platform differences and Bazel version compatibility.

However, there are significant issues with the accompanying tests that need to be addressed:

  1. In tests/py_zipapp/BUILD.bazel, a necessary dependency on absl_py is commented out for one of the test targets. This will cause a runtime failure.
  2. The test implementation files (venv_zipapp_test.py and system_python_zipapp_test.py) have not been updated. They contain assertions that will fail on Windows because they expect a shell script instead of a Windows executable. The tests need to be made platform-aware to properly validate this new functionality.

Fixing these test issues is critical for ensuring the Windows support is robust and verifiable.

@rickeylev
Copy link
Collaborator Author

@gemini-code-assist review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds Windows support for py_zipapp rules by introducing an .exe launcher. The core logic for creating the Windows launcher has been refactored from py_executable.bzl into common.bzl for better reusability. The tests for py_zipapp have been updated to be platform-agnostic and now cover the Windows case. The changes look good and are a welcome improvement. I have one suggestion to refactor a piece of duplicated logic to improve maintainability.

@rickeylev rickeylev marked this pull request as ready for review February 5, 2026 16:41
@rickeylev rickeylev requested a review from aignas as a code owner February 5, 2026 16:41
@rickeylev
Copy link
Collaborator Author

PTAL

@rickeylev rickeylev added this pull request to the merge queue Feb 6, 2026
Merged via the queue into bazel-contrib:main with commit 3aa6386 Feb 6, 2026
4 checks passed
@rickeylev rickeylev deleted the pyzipapp.windows branch February 6, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants